<script>
import ImageControl from './ImageControl'
import ViewControl from './ViewControl'
import TextControl from './TextControl'
import RollTextControl from './RollTextControl'
// import VideoControl from './VideoControl'
import VideoControl20190104 from './VideoControl.20190104.vue' // 旧版，自己播放。app播放完成后删除
import WeatherControl from './WeatherControl'
import CurrentDateControl from './CurrentDateControl'
import CountdownControl from './CountdownControl'

// import autoprefix from '@/modules/corejs/dom-css/autoprefix'
// let transform = autoprefix('transform')
export default {
  render () {
    const { d, index } = this
    let sItem = {
      // [transform]: `translate3d(${d.x}px,${d.y}px,0)`,
      left: d.x + 'px',
      top: d.y + 'px',
      width: d.w + 'px',
      height: d.h + 'px',
      'z-index': d.zIndex
    }

    let vmCont
    switch (d.type) {
      case 1:
        vmCont = <ImageControl d={d}/>
        break
      case 2:
        vmCont = <ViewControl d={d}/>
        break
      case 3:
        vmCont = <TextControl d={d}/>
        break
      case 4:
        vmCont = <RollTextControl d={d} index={index}/>
        break
      case 5:
        if (!(window.jselectronic && window.jselectronic.videoControl)) {
          vmCont = <VideoControl20190104 d={d}/>
        }
        break
      case 6:
        vmCont = <CurrentDateControl d={d}/>
        break
      case 7:
        vmCont = <WeatherControl d={d}/>
        break
      case 8:
        vmCont = <CountdownControl d={d}/>
        break
    }

    return <div class={{ 'control-item': true }} style={sItem}>{vmCont}</div>
  },
  props: {
    d: Object,
    index: Number
  }
}
</script>

<style scoped src="./index.css"></style>
